//###############
//FILE : FileGoodByeSession.java
//WRITER : Daniel Lowengrub, daniel_i_l, 320687098
//EXERCISE : oop ex3 2011
//DESCRIPTION:
//See below
//###############

package oop.ex3.protocol.sessions;

import oop.ex3.protocol.messages.GoodByeMsg;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import oop.ex3.exceptions.InvalidMessageException;

/**
 * Notify a NS that we're shutting down.
 * @author daniel
 */
public class FileGoodByeSession extends FileToNameSession {

    public FileGoodByeSession() {
        super();
    }


    @Override
    protected boolean specExecuteSession(DataInputStream inputStream, DataOutputStream outputStream) throws IOException, InvalidMessageException {
    	if (!initSession(inputStream, outputStream))
        	return false;

        GoodByeMsg goodBye = new GoodByeMsg();
        goodBye.send(outputStream);
        _done.receive(inputStream);

        if (!endSession(inputStream, outputStream))
            return false;
        
        return true;
    }

}
